package com.gok.seasonmovie.controller;

import com.gok.seasonmovie.entity.Comment;
import com.gok.seasonmovie.entity.Img1;
import com.gok.seasonmovie.entity.Img2;
import com.gok.seasonmovie.service.CommentService;
import com.gok.seasonmovie.service.ImgService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class ImgController {

    @Resource
    private ImgService imgService;

    @GetMapping("/getImg1")
    public Map<String, Object> getImg1() {
        try{
            Map<String, Object> response = new HashMap<>();
            response.put("code", 200);
            response.put("msg", "ok");
            List<Img1> data= imgService.getImg1();
            response.put("data", data);
            return response;
        }catch (RuntimeException e) {
            Map<String, Object> errorResponse = new HashMap<>();
            errorResponse.put("code", 600);
            errorResponse.put("msg", "Database error: " + e.getMessage());
            return errorResponse;
        }

    }

    @GetMapping("/getImg2")
    public Map<String, Object> getImg2() {
        try{
            Map<String, Object> response = new HashMap<>();
            response.put("code", 200);
            response.put("msg", "ok");
            List<Img2> data= imgService.getImg2();
            response.put("data", data);
            return response;
        }catch (RuntimeException e) {
            Map<String, Object> errorResponse = new HashMap<>();
            errorResponse.put("code", 600);
            errorResponse.put("msg", "Database error: " + e.getMessage());
            return errorResponse;
        }

    }

    @GetMapping("/getImg3")
    public Map<String, Object> getImg3() {
        try{
            Map<String, Object> response = new HashMap<>();
            response.put("code", 200);
            response.put("msg", "ok");
            List<Img1> data= imgService.getImg3();
            response.put("data", data);
            return response;
        }catch (RuntimeException e) {
            Map<String, Object> errorResponse = new HashMap<>();
            errorResponse.put("code", 600);
            errorResponse.put("msg", "Database error: " + e.getMessage());
            return errorResponse;
        }

    }
}
